--[[ 编码: WMS-51-01 名称: 货位-创建前 作者:HAN 日期:2025-1-29 级别:固定 (说明本段代码在项目中不太会变化) 函数: BeforeDataObjCreate 功能: 1)生成配盘编码 S_DC_NO, 格式:DC221212-00001 更改记录: --]] wms_base = require( "wms_base" ) function BeforeDataObjCreate ( strLuaDEID ) local nRet, strRetInfo nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_DC_NO", "N_B_STATE" ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end local obj_attrs = json.decode( strRetInfo ) local strCode = obj_attrs[1].value -- 配盘码 local b_state = lua.Get_NumAttrValue( obj_attrs[2].value ) -- 生成【配盘】编码 if ( strCode == '' ) then local strHeader = 'DC'..os.date("%y%m%d")..'-' nRet,strCode = mobox.getSerialNumber( "配盘", strHeader, 5 ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), '申请【配盘】编码失败!'..strCode ) end end -- 根据字典获取 N_PURPOSE 的显示名称 local str_state = wms_base.GetDictItemName( strLuaDEID, "WMS_DistributionState", b_state ) -- 设置信息 local attr_value = {} attr_value[1] = lua.KeyValueObj( "S_DC_NO", strCode ) attr_value[2] = lua.KeyValueObj( "S_B_STATE", str_state ) nRet, strRetInfo = mobox.setCurEditDataObjAttr( strLuaDEID, lua.table2str(attr_value) ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "设置【配盘】信息失败! "..strRetInfo ) end end